<template>
	<view>
		<!-- <image src="../../static/noticebanner.png" class="banner"></image> -->
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(value,key) in res" :key="key" @click="jump" :data-id="value.id">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list">
					<view class="uni-media-list-logo">
						<image v-if="value.thumb != ''" :src="value.thumb"></image>
						<!-- <image v-else src="../../static/notice.jpg" mode=""></image> -->
					</view>
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top ellipsis-1" v-cloak>{{value.title}}</view>
						<view class="uni-media-list-text-bottom uni-ellipsis" v-cloak>{{value.createtime}}</view>
					</view>
				</view>
			</view>
		</view>
		<uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		data() {
			return {
				res:[],
				index:2,
				loadingType:0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				load: 0
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.request({
				url: 'http://m.wpweipin.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=shop.notice.get_list&app=1&page=1',
				success: res => {
					this.res = res.data.result.list
					if(res.data.result.total > res.data.result.pagesize){
						this.load = 1
					}
					uni.hideLoading();
				},
				fail: () => {},
				complete: () => {}
			});
		},
		onReachBottom(){
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: 'http://m.wpweipin.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=shop.notice.get_list&app=1&page='+this.index,
				success: res => {
					if(res.data.result.list.length == 0){
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1
				},
				fail: () => {},
				complete: () => {}
			});
			
		},
		components: {uniLoadMore},
		methods:{
			jump(e){
				var id = e.currentTarget.dataset.id
				uni.navigateTo({
					url: 'detail?newsid='+id
				});
			}
		}
	}
</script>

<style>.banner{width:750upx;height:374upx;display:block;}</style>